import { MAIN_MENU } from 'services/Config'

const MainMenu = {
  state: {
    AsideDefaultActive: '1-1', // 当前默认活动菜单-默认首页
    AsideMenu: MAIN_MENU // 侧边栏菜单
  },
  mutations: {
    // 路由改变导致菜单变化
    SetMenuByRouteChange (state, v) {
      MAIN_MENU.forEach((menu, index) => {
        if (menu.route === v.routeName) {
          state.AsideDefaultActive = `${index + 1}`
        }
        menu.children &&
        menu.children.forEach((i, num) => {
          if (i.route === v.routeName) {
            state.AsideDefaultActive = `${index + 1}-${num + 1}`
          }
        })
      })
    }
  }
}

export default MainMenu
